#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define lc (o<<1)
#define rc (o<<1|1)
using namespace std;
typedef long long LL;
typedef double db;
inline LL read()
{
	LL x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=1e5+10;
int n,m;
struct Seg_T
{
	LL sumv[MAXN<<2],flag[MAXN<<2];
	inline void push_up(int o)
	{
		sumv[o]=sumv[lc]+sumv[rc];
		flag[o]=flag[lc]&flag[rc];
		return;
	}
	void build(int o,int l,int r)
	{
		if(l==r)return (void)(sumv[o]=read());
		int mid=(l+r)>>1;
		build(lc,l,mid);
		build(rc,mid+1,r);
		push_up(o);
		return;
	}
	void update(int o,int l,int r,int yl,int yr)
	{
		if(flag[o])return;
		if(l==r)
		{
			sumv[o]=sqrt(sumv[o]);
			if(!sumv[o]||sumv[o]==1)flag[o]=true;
			return;
		}
		int mid=(l+r)>>1;
		if(yl<=mid)update(lc,l,mid,yl,yr);
		if(yr>mid)update(rc,mid+1,r,yl,yr);
		push_up(o);
		return;
	}
	LL query(int o,int l,int r,int yl,int yr)
	{
		if(yl<=l&&r<=yr)return sumv[o];
		int mid=(l+r)>>1;
		LL ans=0;
		if(yl<=mid)ans=query(lc,l,mid,yl,yr);
		if(yr>mid)ans+=query(rc,mid+1,r,yl,yr);
		return ans;
	}
}T1;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=read();
	T1.build(1,1,n);
	m=read();
	while(m--)
	{
		int op=read(),x=read(),y=read();
		if(x>y)swap(x,y);
		if(!op)T1.update(1,1,n,x,y);
		else printf("%lld\n",T1.query(1,1,n,x,y));
	}
	return 0;
}
